import Vue from 'vue'
import Router from 'vue-router'
import login from '@/views/login/login' //登录页面
import index from '@/views/Home/index'  //首页
import date from '@/components/date/date' //日程表控件
import tabExcel from '@/components/tabExcel/tabExcel' //表格和Excel导出控件
import uploadExcel from '@/components/tabExcel/uploadExcel'  //导入
import tinymce from '@/components/Tinymce/tinymce' //富文本编辑器

//配置路由的参数
import routerArr from './configure.js'

import editor from '@/views/editor/editor' //百度富文本编辑器

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueRouter from 'vue-router';

import cookies from 'vue-cookies'

Vue.use(Router)
Vue.use(ElementUI);

const router = new VueRouter({
  routes:routerArr
})


// router.beforeEach((to,from,next)=>{
//   /*
//   执行next()以后，beforeEach循环将来不会继续执行。
//   执行next({path: "/login"});  beforeEach循环还会继续执行，得找一个出口才行
//   */
//   let username = cookies.get('username') || localStorage.username
//   if( to.name === "login" && !username){
//     next()
//   }else if(username){
//     if(to.name === "login"){
//       next({path: "/"});
//     }else{
//       next()
//     }
//   }else{
//     next({path: "/login"});
//   }
// })

export default router